#include <iosfwd>

#include "EndOfCentralDirectory.h"
#include <iostream>
#include <fstream>

EndOfCentralDirectory::EndOfCentralDirectory()
{
    this->eocDirSignature_ = EOCDIRECTORYSIGNATURE;
    this->numOfThisDisk_ = 0;
}

EndOfCentralDirectory::~EndOfCentralDirectory()
{
    if(this->comment_)
        delete[] this->comment_;
}

std::ostream& operator<<(std::ostream& out, EndOfCentralDirectory& endOfCentralDirectory)
{
    out.write((char*) &endOfCentralDirectory.eocDirSignature_, 4);
    out.write((char*) &endOfCentralDirectory.numOfThisDisk_, 2);
    out.write((char*) &endOfCentralDirectory.centralDirStartOnDisk_, 2);
    out.write((char*) &endOfCentralDirectory.numOfcentralDirRecordsOnThisDisk_, 2);
    out.write((char*) &endOfCentralDirectory.totalNumOfcentralDirRecords_, 2);
    out.write((char*) &endOfCentralDirectory.sizeOfCentralDir_, 4);
    out.write((char*) &endOfCentralDirectory.offsetOfStartOfCentralDir_, 4);
    out.write((char*) &endOfCentralDirectory.commentLength_, 2);
    out.write(endOfCentralDirectory.comment_, endOfCentralDirectory.commentLength_);
    
    return out;
}